package com.ruoyi.fapp.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.fapp.model.LoginUserResp;
import com.ruoyi.fapp.service.AppSysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/app/sys")
public class AppSysController extends BaseController {


    @Autowired
    AppSysService appSysService;

    //登录
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginBody loginBody) {
        LoginUserResp loginUserResp = appSysService.appSyslogin(loginBody);

        return AjaxResult.success("登录成功",loginUserResp);

    }

    //注册
    @PostMapping("/register")
    public AjaxResult register(@RequestBody LoginBody loginBody) {

        appSysService.appSysloginregister(loginBody);
        return AjaxResult.success("注册成功");
    }

    //退出登录
    @GetMapping("/logout")
    public AjaxResult logout() {


        appSysService.appSysloginlogout();

        return AjaxResult.success("退出成功");
    }


    //忘记密码
    @PostMapping("/forget")
    public AjaxResult forget(@RequestBody LoginBody loginBody) {

        appSysService.appSysloginforget(loginBody);

        return AjaxResult.success("修改成功");
    }


}
